package solutions.leetcode.easy;

import solutions.lib.BaseSolution;

/**
 * @author lizhidong
 * <a href="https://leetcode-cn.com/problems/consecutive-characters/">1446.连续字符</a>
 */
public class Solution1446 extends BaseSolution {

    public int maxPower(String s) {
        int maxPower = 1;
        int nowPower = 1;
        char nowChar = s.charAt(0);

        int p = 1;
        int len = s.length();
        while (p < len) {
            char c = s.charAt(p++);
            if (nowChar == c) {
                nowPower++;
            } else {
                if (nowPower > maxPower) {
                    maxPower = nowPower;
                }
                nowPower = 1;
                nowChar = c;
            }
        }
        return Math.max(nowPower, maxPower);
    }

    public static void main(String[] args) {
        Solution1446 solution = new Solution1446();
        System.out.println(solution.maxPower("tourist"));
    }
}